import {getItineraryInfoByIdForUser} from '../../api/home'
import { imageURL } from '../../../utils/request'
Component({
  properties: {
    // visible: { type: Boolean, value: true }, // 父組件控製是否顯示
    itinerary_id: {
      type: String,
      value: ''
    },
    height: {
      type: String,
      value: '48' // 默認標題
    },
    width: {
      type: String,
      value: '48' // 默認標題
    },
  },
  data: {
    showModal: false,//邀請好友彈框
    visible: false,
    imageURL:'',
    actionShow:false,
    currentId: null,      // 當前點擊的分類id
    avatars: [
      "/pages/assets/image/avatar.jpg",
      "/pages/assets/image/avatar.jpg",
      "/pages/assets/image/avatar.jpg"
    ],
    list: [
      { id: 1, name: "個人證件", open: true,
        items: [
          { name: "學生證", checked: true },
          { name: "身份證", checked: false },
          { name: "港澳通行證", checked: false },
          { name: "駕駛證", checked: false },
        ]
      },
      { id: 2, name: "數碼產品", open: true,
        items: [
          { name: "充電寶", checked: false },
          { name: "耳機", checked: false },
          { name: "充電線", checked: false },
          { name: "相機", checked: false },
          { name: "手機", checked: false },
          { name: "無人機", checked: false },
        ]
      }
    ],
    //添加彈框
    showSelectPopup: false,//選擇類別
    showAddPopup:false, //添加物品
    showAddMember:false,//添加成員
    newFolderName: '',
    selectedFolder: '',
    folderList: ['個人證件', '數碼產品', '服裝鞋襪', '生活用品','食品飲料','境外必備','戶外用品','藥品','其他',], // 模擬的收藏夾
    userImg: '',
    itineraryDetail:{}
  },
  lifetimes: {
    attached() {
      this.setData({
        imageURL,
      })
      this.getData()
    }
  },
  methods: {
    async getData(){
      const res = await getItineraryInfoByIdForUser({
        itinerary_id:this.properties.itinerary_id
      })
      this.setData({
        itineraryDetail:res.data.info
      })
    },
    onInvite(){
      this.setData({ showModal: false }); 
    },
    // 分享给好友
    onShareAppMessage() {
      return {
        title: this.data.itineraryDetail.name,   // 分享标题
        path: `/pages/Itinerary/myItineraryDetails/myItineraryDetails?itinerary_id=${this.data.itineraryDetail.itinerary_id}`,    // 分享路径（进入页面的地址）
        imageUrl: this.data.imageURL+this.data.itineraryDetail.img_url_cover // 可选：自定义分享封面图
      }
    },
    openModal() {
      this.setData({ showModal: true });
    },
    colse() {
      this.setData({ showModal: false });
    },
    stopBubble() {
      // 阻止點擊 modal-box 冒泡關閉模態框
    }, 
  }
});
